home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue46 / Clinic / AutomationClient1BMainFormU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-03-12  |  1.0 KB  |  54 lines

  1. unit AutomationClient1BMainFormU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls;
  8.  
  9. type
  10.   TFrmClient1 = class(TForm)
  11.     Timer1: TTimer;
  12.     Label1: TLabel;
  13.     procedure FormCreate(Sender: TObject);
  14.     procedure Timer1Timer(Sender: TObject);
  15.   private
  16.     Server: Variant;
  17.   end;
  18.  
  19. var
  20.   FrmClient1: TFrmClient1;
  21.  
  22. implementation
  23.  
  24. uses
  25.   ComObj;
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TFrmClient1.FormCreate(Sender: TObject);
  30. begin
  31.   try
  32.     Server := GetActiveOleObject('AutomationServer1.Clock');
  33.   except
  34.     on EOleSysError do
  35.       Server := CreateOleObject('AutomationServer1.Clock')
  36.   end;
  37.   Timer1.Enabled := True
  38. end;
  39.  
  40. procedure TFrmClient1.Timer1Timer(Sender: TObject);
  41. begin
  42.   try
  43.     Label1.Caption := DateTimeToStr(Server.DateAndTime)
  44.   except
  45.     on E: Exception do
  46.     begin
  47.       TTimer(Sender).Enabled := False;
  48.       Label1.Caption := Format('%s: %s', [E.ClassName, E.Message])
  49.     end
  50.   end
  51. end;
  52.  
  53. end.
  54.